//
//  MusicListViewModel.swift
//  Ios项目forQQ音乐
//
//  Created by Ann on 2017/9/21.
//  Copyright © 2017年 Ann. All rights reserved.
//

import Foundation

//2.4 创建储存数据列表ViewModel
class MusicListViewModel {

    lazy var musicList = [MusicViewModel]()
    
   
  //2.5 加载plist文件获取模型数组
    func loadMusicList(finished:(_ isSuccessed:Bool)->()){
    
        let filePath = Bundle.main.path(forResource: "Musics.plist", ofType: nil)
        guard (filePath != nil) else {
           finished(false)
            return
        }
        guard let arr = NSArray(contentsOfFile: filePath!) as? [[String:AnyObject]] else {
              finished(false)
            return
        }
        for dict in arr {
            musicList.append(MusicViewModel(ms: MusicModel(dict: dict)))
            
        }
        
        finished(true)
        

    }
    
    var description:String {
        var arr = [ String ]()
        
        for des in musicList {
            
         let s = des.description
         arr.append(s)
            
        }
        
        return arr.description
         }

}
